<script setup lang="ts">
	import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
	import QQMapWX from "@/common/qqmap-wx-jssdk.js"
	import useAppStore from "@/store/app.ts"

	const appStore = useAppStore()

	function getLocationInfo() {
		uni.getLocation({
			success(res) {
				const qqmapsdk = new QQMapWX({
					key: 'AVSBZ-B3J3G-7HSQ7-I3P4I-RNLNJ-6QFKB'
				});
				qqmapsdk.reverseGeocoder({
					longitude: res.longitude,
					latitude: res.latitude,
					success(response) {
						let info = response.result;
						const location = {
							...info.address_component,
							lon: res.longitude,
							lat: res.latitude
						}
						appStore.setLocation(location)
					}
				});
			}
		})
	}

	onLaunch(() => {
		// 获取定位信息
		// getLocationInfo()
	});
	onShow(() => {

	});
	onHide(() => {
		console.log("App Hide");
	});
</script>
<style lang="scss">
	page {
		background: #f5f5f5;
	}

	@import "uview-plus/index.scss";
	@import "@/common/style/flex.css";
	@import "@/common/style/layout.css";
	@import "@/uni.scss";
</style>